package feature;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ken
 * Date: 2023-11-26
 * Time: 19:18
 */
public class ReturnOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要归还的图书名字");
        String name = scanner.nextLine();
        int countsize = bookList.getUsedSize();
        for (int i = 0; i < countsize; i++) {
            Book temp = bookList.getBooks(i);
            if (temp.getName().equals(name) &&      //找到并且 有被借出
                    (temp.isIsborrow())) {
                temp.setIsborrow(false);
                System.out.println("归还成功");
                System.out.println(temp);
                return;
            }
        }
        System.out.println("没有找到你要归还的图书名字");
    }
}

